@extends('layouts.mobile')

@section('title', '设置登录密码')

@section('content')
    <div class="security">
        <form class="form">
            <div class="form-group">
                <input type="password" id="password" class="form-control" placeholder="请输入登录密码">
            </div>
            <div class="form-group">
                <input type="password" id="password2" class="form-control" placeholder="请确认密码">
            </div>
            <div class="blank"></div>
            <div class="form-group">
                <button type="button" id="submitButton" class="btn btn-lg btn-primary">提交</button>
            </div>
        </form>
    </div>
@stop

@section('foot')
    <script type="text/javascript">
        $("#submitButton").on('tap', function () {
            var password = $("#password").val();
            if (!DSXValidate.IsPassword(password)){
                DSXUI.showToast('密码输入错误, 请重新输入');
                return false;
            }

            var password2 = $("#password2").val();
            if (!password2) {
                DSXUI.showToast('请确认密码');
                return false;
            }

            if (password !== password2) {
                DSXUI.showToast('两次密码不一致，请重新输入');
                return false;
            }

            $.ajax({
                type:'POST',
                url:'/mobile/security/setpassword',
                data:{password:password, formsubmit:'yes'},
                success:function (response) {
                    DSXUI.showToast('密码修改成功', 1500, function () {
                        window.history.go(-1);
                    });
                }
            })
        });
    </script>
@stop
